All Questions
25 questions
1vote
2answers
81views
Extracting items from comma/semicolon-delimited strings, discarding parts after a hyphen
New Scala dev here. Is there a more idiomatic or efficient way to accomplish this in Scala? Given a list of the following strings, I need to obtain the unique 'main parts' once any parts including ...
1vote
1answer
157views
Find Permutations of String in Scala
Given a smaller strings and a bigger string b, design an algorithm to find all permutations of the shorter string within the longer one. ...
3votes
3answers
2kviews
Concatenating optional strings in Scala
I have two optional strings, any of them can be None. I want to create their combination with a delimiter between them if they both exist. I expect to be able to come with a more concise and nicer ...
3votes
1answer
70views
Scala: Cumulative String Tokenisation
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below, ...
3votes
1answer
94views
Clean up tags from a text
I need to generate random text for tests. I do that using alphanumeric characters and some special characters as well. For some special cases, I cannot generate the random text with tags. I have the ...
1vote
2answers
334views
Count Substrings for a binary string
Problem is taken from leet code. Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings ...
2votes
0answers
319views
KMP algorithm in scala
I implemented KMP pattern matching algorithm in Scala. My code works but it looks more imperative and a scala translation of C/C++ implementation. I am not able to figure out how to manage multiple ...
1vote
1answer
121views
Find first repeating Char in String
Given a string, find the first repeating character in it. Examples: firstUnique("Vikrant") → None ...
0votes
1answer
531views
Print words in decreasing order of frequency in Scala
Given a string print its words in decreasing order of frequency. Example: i/p - "aa bbb ccc aa ddd aa ccc" o/p - aa,ccc,ddd,bbb Scala: ...
0votes
1answer
385views
find if one string is a valid anagram of another , in scala
Question is taken from leet code. Problem Given two strings s and t , write a function to determine if t is an anagram of s. Examples ...
4votes
1answer
929views
Longest Substring Without Repeating Characters in Scala
Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
1vote
1answer
497views
Check Is Anagram Scala HashMap based implementation
Here is the HashMap based implementation of the function checking whether two strings are anagrams: Example: ...
4votes
3answers
137views
Compare ZIP codes, disregarding leading zeros
I have a function that compares ZIP codes. It also has to handle cases where the input ZIP code be missing leading zeros, have extraneous leading zeros. This is what I've come up with. I don't have ...
1vote
2answers
233views
Find the most frequent character in a string
I'm trying to solve this problem https://community.topcoder.com/stat?c=problem_statement&pm=40 Given a string made up of ONLY letters and digits, determine which character is repeated the ...
2votes
1answer
109views
Generate a sequence of coin flips until pattern is hit
A book on probability says that a sequence of heads and tails is generated by a fair coin asking what is the probability that the pattern T, H, H, H occurs before the pattern H, H, H, H. I have made a ...